package com.shujia.wyh.day16;

/*
        截取功能
            public String substring(int start)
            public String substring(int start,int end)

 */
public class StringBufferDemo6 {
    public static void main(String[] args) {
        StringBuffer sb = new StringBuffer();
        sb.append("hello")
                .append("world")
                .append("java")
                .append("hadoop")
                .append("hive");

        System.out.println("sb:" + sb);
        System.out.println("===================================");
        //public String substring(int start)
        String s = sb.substring(5);
        System.out.println("截取出来的字符串为：" + s);
        System.out.println("截取后的StringBuffer为：" + sb);
        System.out.println("==================================");
        //public String substring(int start,int end)
        String s2 = sb.substring(14, 20);
        System.out.println("截取出来的字符串为：" + s2);
        System.out.println("截取后的StringBuffer为：" + sb);
        System.out.println("=====将StringBuffer中的字符串全部转成String类型====");
        String s3 = sb.substring(0);
        System.out.println(s3);


    }
}
